<%@ page contentType="text/html;charset=UTF-8" %>

<!DOCTYPE html>
<html>
<head>
	<title>属性管理</title>
	 <%@ include file="/common/meta.jsp" %>
	<%@ include file="/common/import.jsp" %>
	<script type="text/javascript" src="${ctx}/js/zbxtools.js"></script>
	<script type="text/javascript">
		$(function(){
			$('#unitSaveForm').form({
				 onSubmit:function(){	
					$("#dataType").removeAttr("disabled");
					$("#dataRestrict").removeAttr("disabled");
			    	return $(this).form('validate');
			    },
			    success:function(data){
			    	var result = jQuery.parseJSON(data);
			    	if(result.flag=='T'){
			    		$.messager.alert('提交结果', '操作成功!', 'info',function(){
				    		parent.closeAdd();
				    		parent.reload();
			    		});
			    	}else{
			    		$.messager.alert('提交结果', result.msg, 'error');
			    	}        
			    }
			});
		});
	</script>

<body>	

	<form id="unitSaveForm" name="unitSaveForm" method="post" action="save.action">
		<input type="hidden" name="formToken" id="formToken" value="${formToken}"/>
		<input type="hidden" name="metadataId" id="metadataId" value="${item.metadataId}"/>
		<input type="hidden" name="sortId" id="sortId" value="${item.sortId}"/>
		<table class="datagrid-body" >
			<tr>
				<td class="datagrid-header">全称<font color="red">*</font></td>
				<td>
				<input id="dataFullName" name="dataFullName"  value="${item.dataFullName}"
				class="easyui-validatebox" data-options="required:true,validType:'length[2,30]'" size="30" " 
				missingMessage="请输入全称" invalidMessage="应为2~30个字" />
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">字段名称<font color="red">*</font></td>
				<td>
				<input name="dataShortName" onchange="setdataShortName()"  id="dataShortName" value="${item.dataShortName}"
				<c:if test="${sortStatus == '1'}"> readonly="readonly" </c:if>
				class="easyui-validatebox" data-options="required:true,validType:'length[2,25]'" size="30" 
				missingMessage="请输入字段名称" invalidMessage="应为2~25个字" />				
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">属性名称<font color="red">*</font></td>
				<td>
				<input name="dataAttr"  id="dataAttr" value="${item.dataAttr}" readonly="readonly"/>				
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">数据类型<font color="red">*</font></td>
				<td>
				   <select name="dataType" id="dataType">
					   <option value="5" selected="selected">字符-VARCHAR2</option>
					   <option value="1">整型-NUMBER</option>
					   <option value="2">长整型-NUMBER</option>
					   <option value="3">小数-NUMBER</option>
					   <option value="4">字节-CHAR</option>
					   <option value="6">日期-DATE</option>
					</select>
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">数据长度<font color="red">*</font></td>
				<td>
				<input name="dataLength"  id="dataLength" value="${item.dataLength}"
				class="easyui-validatebox" data-options="required:true" size="30" missingMessage="请输入数据长度" />				
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">数据约束<font color="red">*</font></td>
				<td>
				<select name="dataRestrict" id="dataRestrict" >
					   <option value="3" selected="selected">可空</option>
					   <option value="1">主键</option>
					   <option value="2">非空</option>
					</select>
				</td>
			</tr>
			
		   <tr><td class="datagrid-header">列类型<font color="red">*</font></td><td>
			  <select name="colmunType" id="colmunType">
				  <option value="input" selected="selected">输入框</option>
				  <option value="radio">单选</option>
				  <option value="checkbox">多选</option>
				  <option value="select">下拉列表</option>
				  <option value="textarea">文本域</option>
			  </select>
		  </td></tr>
		  <tr><td class="datagrid-header">请求URL<font color="red">*</font></td>
		  <td><input name="reqUrl" id="reqUrl" size="50" class="easyui-validatebox" value="${item.reqUrl}" /></td></tr>
		  <tr><td class="datagrid-header">返回列<font color="red">*</font></td>
		  <td><input name="resColmun" id="resColmun" size="50" class="easyui-validatebox"  value="${item.resColmun}"/></td></tr>
			<tr >
				<td class="datagrid-header">排序条件</td>
				<td>
				<input name="reserved1"  id="reserved1" value="${item.reserved1}"
				class="easyui-validatebox"  size="30" title="如：desc" />				
				</td>
			</tr>
			<tr>
				<td class="datagrid-header"></td>
				<td >
					<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="$('#unitSaveForm').submit();">提交</a>	
					<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="parent.closeAdd();"; >取消</a>		
				</td>
			</tr>
		  
		</table>
	</form>
</body>
<script>
	ZBXTools.initSelect("dataType","${item.dataType}");
	ZBXTools.initSelect("dataRestrict","${item.dataRestrict}");
	ZBXTools.initSelect("colmunType","${item.colmunType}");
	var status ="${sortStatus}";
	if("1"==status){
		$("#dataType").attr("disabled","disabled");
		$("#dataRestrict").attr("disabled","disabled");
	}
	function setdataShortName(){
		var dataShortName = $("#dataShortName").val();
		$("#dataAttr").val(transformStr3(dataShortName));
	}	
	//字符串转成驼峰的方法
	function transformStr3(str){
	    var re=/_(\w)/g;
	    return str.replace(re,function ($0,$1){
	        return $1.toUpperCase();
	    });
	}
</script>
</html>